<script>
	import userApi from './api/user.js'
	import { logout } from './common/action.js'

	const info = {}
	export default {
		globalData: {
			userInfo: null
		},
		getInfo() {
			return new Promise((resolve, reject) => {
				userApi.infoTest().then(res => {
					this.info = res
					this.isLogin = "isLogin";
					resolve(res)
				})
			})
		},
		init() {
			return new Promise((ok, no) => {
				if (!this.token) {
					this.token = uni.getStorageSync('token')
				}
				if (this.token) {
					this.getInfo().then(res => {
						ok()
					})
				} else {
					logout()
				}
			})
		},
		onLaunch: function() {
			info.coolStart = true
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang='scss'>
/*每个页面公共css */
@import "uview-ui/index.scss";
</style>
